from graph import Graph
G = Graph((100,100),10)
obstacle = [(2,2),(2,3), (2,4)]
G.set_obstacle(obstacle)

start_point = (0,0)
end_point = (G.m - 1, G.n - 1)
def get_neighbors(p):
    neighbors = []
    delta = [(0,1),(0,-1),(1,0),(-1,0)]
    for d in delta:
        x = p[0] + d[0]
        y = p[1] + d[1]
        if (x >= 0 and x < G.m) and (y >= 0 and y < G.n) and (G.mat[x][y] == 1):
            neighbors.append((x,y))
    return neighbors

visited = set()
def DFS(start_point, end_point):
    visited.add(start_point)
    G.mat[start_point[0]][start_point[1]] = -1
    print("current: ", start_point)

    neighbors = get_neighbors(start_point)
    
    print('neighbors: ', neighbors)
    for neighbor in neighbors:
        if neighbor == end_point:
            print('arrived')
            return 
        else:
        
            if neighbor not in visited:
                visited.add(neighbor)
                G.mat[neighbor[0]][neighbor[1]] == -1
                print(G.mat)
                DFS(neighbor, end_point)
            else:
                pass

DFS(start_point, end_point)
print(G.mat)
